/*
   Exercise 5.1
 Count from 0~255 in binary
 with two paralled displays using
 
 CC by-sa 3.0
 http://tronixstuff.wordpress.com
 based on work by Carlyn Maw and Tom Igoe
 */
int latchpin = 8; // connect to pin 12 on the '595
int clockpin = 12; // connect to pin 11 on the '595
int datapin = 11; // connect to pin 14 on the '595
void setup()
{
   pinMode(latchpin, OUTPUT);
   pinMode(clockpin, OUTPUT);
   pinMode(datapin, OUTPUT);
}
void loop()
{
   for (int loopy=0; loopy<256; loopy++)
   {
     digitalWrite(latchpin, LOW);
     shiftOut(datapin, clockpin, MSBFIRST, loopy);
     // this will send 'loopy' to the first shift register connected
     // to the arduino
     shiftOut(datapin, clockpin, MSBFIRST, loopy);
     // this will send 'loopy' again, into the first shift register
     // as it already has a byte of data, it pushed it over to the next
     // shift register. 
     digitalWrite(latchpin, HIGH);
     delay(200);
   }
}

